package com.sunwayworld.basemodule.common.asynctask.validator;

import com.sunwayworld.baseline.framework.utils.MemoryMonitoringUtils;
import com.sunwayworld.framework.validator.data.DataValidator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Repository;

@Repository
public class MemoryValidator implements DataValidator {
	
	Logger logger = LogManager.getLogger(MemoryValidator.class);

	@Override
	public boolean doValid(Object... args) {
		boolean checkMemory = MemoryMonitoringUtils.checkMemoryUsage(60);
		if (!checkMemory){
			addConstraintViolation("系统资源紧张，请稍后尝试!");
			return false;
		}
		return true;
	}

}
